<!DOCTYPE html>
<html lang="en">
	<head>
    	<meta name="layout" content="main_mobile">
        <title>一起捐详情</title>       
	    <link rel="stylesheet" href="${resource(dir: 'css', file: 'user_account_2.0.css')}" type="text/css">
	    <script type="text/javascript" src="${resource(dir: 'js', file: 'jquery-1.10.2.js')}" ></script>  
	    <script src="/scfire/venobox/venobox.min.js"></script>
	    <script src="/scfire/js/jquery-migrate-1.2.1.min.js"></script>
	    <style type="text/css">
	    #load{
			font-size: 15px;
		    text-align: center;
		    color: #a89e99;
		    padding: 8px 0;
	    }
	    </style>
    </head>
<body>
	<section class="ui-container" style="padding-bottom: 5px;">
		<ul class="ui-tiled user-donate ui-border-b">
            <li>
                <div class="num"><em>${subprojectsNum }</em>次</div>
                <div>发起一起捐</div>
            </li>
            <li>
                <div class="num"><em>${donateNum }</em>位</div>
                <div>小伙伴参与</div>
            </li>
            <li>
                <div class="num"><em><g:formatNumber number="${totalMoney }" format="0.00"/></em>元</div>
                <div>共募善款</div>
            </li>
        </ul>
        <div class="ui-module-title ui-border-tb">我发起的一起捐</div>
		<ul class="ui-list ui-border-b user-account" id="myinit">
		
			<%--<g:each in="${subprojects}" var="subproject">
			<li class="ui-border-t" onclick="goSubProject('${subproject.id}')">
                <div class="ui-list-img">
                    <span style="background-image:url(/scfire/project/imgRead?img=${subproject.project.img})"></span>
                </div>
                <div class="ui-list-info">
                    <h4 class="ui-nowrap">${subproject.project.name }</h4>
                    <p class="ui-box"><span>已筹<em><g:formatNumber
										number="${subproject.subdonate}" format="0.00" /></em>元</span>  <span>参与数<em>${subproject?.donates?.size()?subproject?.donates?.size():0 }</em>人次</span></p>
                    <p class="ui-nowrap">目标
								<g:if test="${subproject.subamount==-1 }">
									<span class="num"><em>不限</em></span>
								</g:if>
								<g:else>
									<span class="num"><em><g:formatNumber
											number="${subproject.subamount }" format="0.00" /></em></span>元
				               </g:else></p>
                </div>
            </li>
			</g:each>
		--%></ul>
		 <div class="ui-line-more" id="more">
             <p  id='week'>加载完成</p>
        </div>
	</section>


	<script type="text/javascript">
		var finalOffset = 10
		var initoffset = 0
			ajaxReadinit();
		function ajaxReadinit() {
			var html = "";
			$.ajax({
						type : 'get',
						dataType : 'json',
						url : '/scfire/subProject/subList?format=json&offset='
								+ initoffset,
						beforeSend : function() {
							console.log('loading...');
							$("#week").html('加载中...');
						},
						success : function(data) {
							$.each(data,function(i, item) {
								initoffset++
								//html += "<li class='ui-border-t'>"
								html += "<li class='ui-border-t' onclick=\"window.location.href=\'/scfire/subProject/subProjectDetail?subprojectid="+item.subprojectid+"\'\">"								
								html += "<div class='ui-list-img'><span style='background-image:url(/scfire/project/imgRead?img="+ item.img + ")'>"
								html += "</span></div>"
								html += "<div class='ui-list-info'>"
								html += "<h4 class='ui-nowrap'>"
										+ item.name + "</h4>"
								html += "<p class='ui-box'><span>已筹<em>"
										+ item.subdonate.toFixed(2)+ "</em>元</span>"
										
								html += "<span>参与数<em>"+ item.donatenums +"</em>人次</span></p>"
								html += "<p class='ui-nowrap'>"
								html += "目标 <em>"
								if (item.subamount == -1) {
									html += "不限</em>"
								} else {
									html += ""
											+ item.subamount
													.toFixed(2)
											+ "</em>元"
								}
								html += "</p>"
								html += " </li>"

							});
							$("#myinit").append($(html));
							 if(data.length<finalOffset){       				
                  				$("#week").html("已经到底了")
                  				$("#week").removeAttr("onclick");
                  				
                      		}else{
                 	            $("#week").html("加载更多")
                 	            $("#week").attr("onclick","ajaxReadinit()");
                          		}
						},
						complete : function() {
							console.log('mission complete.')
						},
						error : function(data) {
							$("#week").html('已经到底了');
						}

					});
		}

	function goSubProject(id){
		window.location.href="/scfire/subProject/subProjectDetail?subprojectid="+id
	}
	</script>
 

</body>
</html>